home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / misc / compsci / arcsgm.cpt / ARC SGML 1.0 / sgmlc / arclexrf.c next >
Encoding:
C/C++ Source or Header  |  1991-12-17  |  32.2 KB  |  610 lines

  1. #ifdef applec
  2. #pragma segment SegA
  3. #endif
  4. /******************************************************************************/
  5. /* ARCLEXRF: Lexical tables for reference concrete syntax.
  6. */
  7. /*lint -library                  Ignore failure to use library functions. */
  8. #include <stdio.h>            /* Stream I/O functions. */
  9. /*lint -restore                  End of library function declarations. */
  10. #include "entity.h"           /* Templates for entity control blocks. */
  11. #include "synxtrn.h"          /* Declarations for concrete syntax constants. */
  12. #include "action.h"           /* Action names for all parsing. */
  13. #include "adl.h"              /* Definitions for attribute list processing. */
  14. /******************************************************************************/
  15. /* LEXCNM: Lexical table for mixed content (PCBCONM) parse.
  16. */
  17. /* Symbols for SGML character set divisions and function characters. */
  18. #define FRE     0   /* FREECHAR that is not in a CON delimiter-in-context. */
  19. #define NU      1   /* NUMERAL            Numerals */
  20. #define NMC     2   /* LC/UCNMCHAR . -    Period and hyphen */
  21. #define NMS     3   /* LC/UCNMSTRT        Lower and uppercase letters */
  22. #define SPC     4   /* SPACE     32       Space */
  23. #define NON     5   /* NONSGML   0-31 127 255 Unused, except for: */
  24. #define EE      6   /* NONSGML   00 26    Entity end (end of file) */
  25. #define EOB     7   /* NONSGML   28       End disk buffer */
  26. #define RS      8   /* Function  10       Line feed */
  27. #define RE      9   /* Function  13       Carrier return */
  28. #define SEP    10   /* SEPCHAR   09       TAB: horizontal tab */
  29. #define CDE    11   /* NONSGML   delcdata CDATA/SDATA delimiter */
  30. #define NSC    12   /* NONSGML   delnonch Non-SGML character prefix */
  31.  
  32. /* Symbols for SGML delimiter roles in CON and CXT.
  33.    ETI and NET must be the same in LEXCNM and LEXCON.
  34.    FRE characters are changed to FCE if an FCE entity is declared.
  35.    They are changed back to FRE when the entity is canceled.
  36. */
  37. #define ERO    13   /* &    Also CRO[1] */
  38. #define NMRE   14   /* 08   Generated non-markup RE */
  39. #define COM    15   /* -    For MDO context; also SR19 and SR20. */
  40. #define ETI    16   /* /    Actually ETAGO[2] */
  41. #define NET    17   /* /    When enabled. */
  42. #define LIT1   18   /* "    SR10 */
  43. #define SPCR   19   /* Space in use as SR8. */
  44. #define MDO    20   /* !    Actually MDO[2] */
  45. #define MSC1   21   /* ]    Both MSC[1] and MSC[2]; also SR26. */
  46. #define MSO    22   /* [    For MDO context; also SR25. */
  47. #define PIO    23   /* ?    Actually PIO[2] */
  48. #define RNI    24   /* #    For CRO[2]; also SR11. */
  49. #define TGC1   25   /* >    For TAGO and MSC context; also MDC, PIC */
  50. #define TGO1   26   /* <    TAGO; also MDO[1], PIO[1] */
  51. #define FCE    27   /* FRE  Free character in use as an entity reference */
  52.  
  53. UNCH    lexcnm[256] = { /*
  54. 000  001  002  003  004  005  006  007   bs  tab  lf   home ff   cr   so   si   */
  55. EE,  NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS,  NON, NON, RE,  NON, NON, /*
  56. 010   011  012  013  014  015  016   017  020  021    eof  esc  rt   left up   down */
  57. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE,  NON, EOB, NON, NON, NON, /*
  58. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  59. SPC, MDO, LIT1,RNI, FRE, FRE ,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /*
  60. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  61. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO1,FRE, TGC1,PIO, /*
  62. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  63. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  64. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  65. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC1,FRE, FRE, /*
  66. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  67. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  68. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  69. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
  70. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  71. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  72. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  73. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  74. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  75. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  76. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  77. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
  78. };
  79. /*      free nu   nmc  nms  spc  non  ee   eob  rs   re   sep  cde  nsc  ero
  80.         nmre com  eti  lit  spcr mdo  msc  mso  net  pio  rni  tagc tago fce   */
  81. #undef ERO
  82. #undef NMRE
  83. #undef COM
  84. #undef ETI
  85. #undef NET
  86. #undef LIT1
  87. /* def SPCR*/
  88. #undef MDO
  89. #undef MSC1
  90. #undef MSO
  91. #undef PIO
  92. #undef RNI
  93. #undef TGC1
  94. /* def TGO1*/
  95. /* def FCE*/
  96. /******************************************************************************/
  97. /* LEXCON: Lexical table for RCDATA and CDATA content (PCBCON?),
  98.            prolog (PCBPRO), and nested declaration set (PCBMDS) parses.
  99.    Note: NMC is same as FRE; kept for consistency with LEXCNM and LEXLMS.
  100. */
  101. /* Symbols for SGML character set divisions and function characters. */
  102. /* Same as for LEXCNM. */
  103.  
  104. /* Symbols for SGML delimiter roles in CON, CXT, and DS.
  105.    ETI and NET must be the same in LEXCNM and LEXCON.
  106.    FRE characters are changed to FCE if an FCE entity is declared.
  107.    They are changed back to FRE when the entity is canceled.
  108. */
  109. #define ERO    13   /* &    Also CRO[1] */
  110. #define NMRE   14   /* 08   Generated non-markup RE */
  111. #define COM    15   /* -    For MDO context. */
  112. #define ETI    16   /* /    Actually ETAGO[2] */
  113. #define NET    17   /* /    When enabled. */
  114. #define MDO    18   /* !    Actually MDO[2] */
  115. #define MSC2   19   /* ]    Both MSC[1] and MSC[2]. */
  116. #define MSO    20   /* [    For MDO context. */
  117. #define PERO   21   /* %    For prolog */
  118. #define PIO    22   /* ?    Actually PIO[2] */
  119. #define RNI    23   /* #    For CRO[2]. */
  120. #define TGC2   24   /* >    For TAGO and MSC context; also MDC, PIC */
  121. #define TGO2   25   /* <    TAGO; also MDO[1], PIO[1] */
  122.  
  123. UNCH    lexcon[256] = { /*
  124. 000  001 002   003   004  005  006  007      bs   tab  lf   home    ff     cr   so     si   */
  125. EE,  NON, NON, NON, NON, NON, NON, NON, NMRE,SEP, RS,  NON, NON, RE,  NON, NON, /*
  126. 010  011   012  013  014   015   016  017  020  021    eof  esc  rt   left up   down */
  127. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE,  NON, EOB, NON, NON, NON, /*
  128. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  129. SPC, MDO, FRE, RNI, FRE, PERO,ERO, FRE, FRE, FRE, FRE, FRE, FRE, COM, NMC, ETI, /*
  130. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  131. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , FRE, FRE, TGO2,FRE, TGC2,PIO, /*
  132. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  133. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  134. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  135. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC2,FRE, FRE, /*
  136. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  137. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  138. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  139. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
  140. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  141. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  142. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  143. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  144. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  145. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  146. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  147. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
  148. };
  149. /*      free nu   nmc  nms  spc  non  ee   eob  rs   re   sep  cde  nsc  ero
  150.         nmre com  eti  net  mdo  msc  mso  pero pio  rni  tagc tago  */
  151. #undef FRE
  152. #undef NU
  153. #undef NMC
  154. #undef NMS
  155. #undef SPC
  156. #undef NON
  157. #undef EE
  158. #undef EOB
  159. #undef RS
  160. #undef RE
  161. #undef SEP
  162. #undef CDE
  163. #undef NSC
  164. #undef ERO
  165. #undef NMRE
  166. #undef COM
  167. /* def ETI*/
  168. /* def NET*/
  169. #undef MDO
  170. #undef MSC2
  171. #undef MSO
  172. #undef PERO
  173. #undef PIO
  174. #undef RNI
  175. #undef TGC2
  176. /******************************************************************************/
  177. /* LEXGRP: Lexical table for group (PCBGR??) parses, including PCBREF.
  178. */
  179. /* Symbols for SGML character set divisions. */
  180. #define BIT     0   /* Bit combinations (not NONCHAR) not allowed in a group. */
  181. #define NMC     1   /* NAMECHAR  . -      Period, underscore, and numerals */
  182. #define NMS     2   /* NAMESTRT           Lower and uppercase letters */
  183. #define RE      3   /* Function  13       Carrier return */
  184. #define SPC     4   /* SPACE     32 09    Space; includes TAB */
  185. #define NON     5   /* NONCHAR   0-31 127 255 Unused, except for: */
  186. #define EE      6   /* Function  26 00    EE: entity end (end of file) */
  187. #define EOB     7   /* NONCHAR   28       End disk buffer. */
  188. #define RS      8   /* Function  10       RS: record start (line feed) */
  189.  
  190. /* Symbols for SGML delimiter roles in GRP. */
  191. #define AND1    9   /* &    */
  192. #define GRPC   10   /* )    */
  193. #define GRPO   11   /* (    */
  194. #define LIT2   12   /* "    For datatags. */
  195. #define LITA   13   /* '    For datatags. */
  196. #define DTGC   14   /* ]    For datatags. */
  197. #define DTGO   15   /* [    For datatags. */
  198. #define OPT1   16   /* ?    */
  199. #define OR1    17   /* |    */
  200. #define PERO   18   /* %    */
  201. #define PLUS   19   /* +    */
  202. #define REP1   20   /* *    */
  203. #define RNI    21   /* #    For #CHARS */
  204. #define SEQ1   22   /* ,    */
  205. #define REFC   23   /* ;    For references */
  206.  
  207. UNCH lexgrp[256] = { /*
  208. 000  001 002   003   004  005  006  007      bs   tab  lf   home    ff     cr   so     si   */
  209. EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS,  NON, NON, RE,  NON, NON, /*
  210. 010  011   012  013  014   015   016  017  020  021    eof  esc  rt   left up   down */
  211. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /*
  212. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  213. SPC, BIT, LIT2,RNI, BIT, PERO,AND1,LITA,GRPO,GRPC,REP1,PLUS,SEQ1,NMC, NMC, BIT, /*
  214. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  215. NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, NMC, BIT, REFC,BIT, BIT, BIT, OPT1,/*
  216. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  217. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  218. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  219. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DTGO,BIT, DTGC,BIT, BIT, /*
  220. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  221. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  222. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  223. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, OR1, BIT, BIT, NON,
  224. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  225. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  226. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  227. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  228. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  229. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  230. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  231. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON
  232. };
  233. /*      bit  nmc  nms  re   spc  non  ee   eob  rs   and  grpc grpo lit  lita
  234.         dtgc dtgo opt  or   pero plus rep  rni  seq  refc */
  235. #undef BIT
  236. #undef NMC
  237. #undef NMS
  238. #undef RE
  239. #undef SPC
  240. #undef NON
  241. #undef EE
  242. #undef EOB
  243. #undef RS
  244. #undef AND1
  245. #undef GRPC
  246. #undef GRPO
  247. #undef LIT2
  248. #undef LITA
  249. #undef DTGC
  250. #undef DTGO
  251. #undef OPT1
  252. #undef OR1
  253. #undef PERO
  254. #undef PLUS
  255. #undef REP1
  256. #undef RNI
  257. #undef SEQ1
  258. #undef REFC
  259. /******************************************************************************/
  260. /* LEXLMS: Lexical table for literal parses (PCBLIT?) and
  261.            marked sections (PCBMS??).
  262. */
  263. /* Symbols for SGML character set divisions and function characters.
  264. */
  265. #define FRE     0   /* Free char: not in a delimiter or minimum literal. */
  266. #define NU      1   /* Numeral            Numerals */
  267. #define MIN     2   /* Minimum literal    '()+,-./:?= */
  268. #define NMS     3   /* LC/UCNMSTRT        Lower and uppercase letters */
  269. #define SPC     4   /* SPACE     32       Space */
  270. #define NON     5   /* NONSGML   0-31 127 255 Unused, except for: */
  271. #define EE      6   /* NONSGML   00 26    Entity end (end of file) */
  272. #define EOB     7   /* NONSGML   28       End disk buffer */
  273. #define RS      8   /* Function  10       Line feed */
  274. #define RE      9   /* Function  13       Carrier return */
  275. #define SEP    10   /* SEPCHAR   09       TAB: horizontal tab */
  276. #define CDE    11   /* NONSGML   delcdata CDATA/SDATA delimiter */
  277. #define NSC    12   /* NONSGML   delnonch Non-SGML character prefix */
  278. /* Symbols for SGML delimiter roles in LIT, PI, and marked sections.
  279.    Either LIT, LITA, PIC, or EE, is changed to LITC when a literal is begun.
  280.    It is changed back when the LITC occurs (i.e., when the literal ends).
  281. */
  282. #define ERO    13   /* &    */
  283. #define MDO    14   /* !    Actually MDO[2] */
  284. #define MSC3   15   /* ]    Also MSC[2]. */
  285. #define MSO    16   /* [    For MDO context. */
  286. #define PERO   17   /* %    For prolog. */
  287. #define RNI    18   /* #    For CRO[2] */
  288. #define TGC3   19   /* >    Also MDC for MSC context. */
  289. #define TGO3   20   /* <    TAGO; also MDO[1] */
  290. #define LITC   21   /* LIT LITA PIC or EE in use as a literal terminator */
  291.  
  292. /* Room has been left in the parse tables in case re-parsing of text
  293.    is eventually supported (i.e., saved parsed text is used by the
  294.    application to create a new SGML document, but CDATA and SDATA
  295.    entities in literals, and non-SGML characters, are left in their
  296.    parsed state to avoid the overhead of reconstituting the original
  297.    markup).  In such a case, the two non-SGML characters specified by
  298.    the text processor in sw.delcdata and sw.delsdata are changed to CDE.
  299.    NOTE: The idea is a bad one, because the generated document would
  300.    be non-conforming, as it would contain non-SGML characters.
  301. */
  302. /* The character in sw.delnonch is changed to NSC in any event, so that
  303.    a resolved non-SGML character reference in the text of a general entity
  304.    can be handled as data in the content.
  305. */
  306.  
  307. UNCH    lexlms[256] = { /*
  308. 000  001 002   003   004  005  006  007      bs   tab  lf   home    ff     cr   so     si   */
  309. EE,  NON, NON, NON, NON, NON, NON, NON, NON ,SEP, RS,  NON, NON, RE,  NON, NON, /*
  310. 010  011   012  013  014   015   016  017  020  021    eof  esc  rt   left up   down */
  311. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE,  NON, EOB, NON, NON, NON, /*
  312. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  313. SPC, MDO, FRE, RNI, FRE, PERO,ERO, MIN, MIN, MIN, FRE, MIN, MIN, MIN, MIN, MIN, /*
  314. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  315. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , MIN, FRE, TGO3,MIN, TGC3,MIN, /*
  316. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  317. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  318. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  319. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, MSO, FRE, MSC3,FRE, FRE, /*
  320. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  321. FRE, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  322. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  323. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, FRE, FRE, FRE, FRE, NON,
  324. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  325. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  326. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  327. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  328. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  329. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  330. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE,
  331. FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, FRE, NON
  332. };
  333. /*      free nu   min  nms  spc  non  ee   eob  rs   re   sep  cde  nsc  ero
  334.         mdo  msc  mso  pero rni  tago tagc litc */
  335. /* def FRE*/
  336. #undef NU
  337. #undef MIN
  338. #undef NMS
  339. #undef SPC
  340. #undef NON
  341. #undef EE
  342. #undef EOB
  343. #undef RS
  344. #undef RE
  345. #undef SEP
  346. /* def CDE*/
  347. /* def NSC*/
  348. #undef ERO
  349. #undef MDO
  350. /* def MSC3*/
  351. #undef MSO
  352. #undef PERO
  353. #undef RNI
  354. #undef TGC3
  355. #undef TGO3
  356. /* def LITC*/
  357. /******************************************************************************/
  358. /* LEXMARK: Lexical scan table for markup: PCBMD? and PCB?TAG.
  359. */
  360. /* Symbols for SGML character set divisions. */
  361. #define BIT     0   /* Bit combinations not allowed; includes ESC SO SI */
  362. #define NMC     1   /* NAMECHAR  . _      Period and underscore */
  363. #define NU      2   /* NUMERAL            Numerals */
  364. #define NMS     3   /* NAMESTRT           Lower and uppercase letters */
  365. #define SPC     4   /* SPACE     32 13 09 Space; includes RE TAB */
  366. #define NON     5   /* NONCHAR   0-31 127 255 Unused, except for: */
  367. #define EE      6   /* Function  26 00    EE: entity end (end of file) */
  368. #define EOB     7   /* NONCHAR   28       End disk buffer. */
  369. #define RS      8   /* Function  10       RS: record start (line feed) */
  370.  
  371. /* Symbols for SGML delimiter roles in MD and TAG. */
  372. #define COM1    9   /* -    Actually COM[1]; also COM[2], MINUS. */
  373. #define ETIB   10   /* /    ETI; actually ETAGO[2]. */
  374. #define GRPO   11   /* (    */
  375. #define LIT3   12   /* "    */
  376. #define LITA   13   /* '    */
  377. #define DSO    14   /* [    */
  378. #define PERO   15   /* %    */
  379. #define PLUS   16   /* +    */
  380. #define REFC   17   /* ;    For references */
  381. #define RNI    18   /* #    Also CRO[2] */
  382. #define TGC4   19   /* >    Also MDC, PIC */
  383. #define TGO4   20   /* <    TAGO; also MDO[1] */
  384. #define VI     21   /* =    */
  385.  
  386. UNCH lexmark[256] = { /*
  387. 000  001 002   003   004  005  006  007      bs   tab  lf   home    ff     cr   so     si   */
  388. EE , NON, NON, NON, NON, NON, NON, NON, NON, SPC, RS,  NON, NON, SPC, NON, NON, /*
  389. 010  011   012  013  014   015   016  017  020  021    eof  esc  rt   left up   down */
  390. NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, EE , NON, EOB, NON, NON, NON, /*
  391. 032  !    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  392. SPC, BIT, LIT3,RNI, BIT, PERO,BIT, LITA,GRPO,BIT, BIT, PLUS,BIT, COM1,NMC ,ETIB,/*
  393. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  394. NU,  NU,  NU,  NU,  NU,  NU,  NU,  NU,  NU,  NU,  BIT, REFC,TGO4,VI,  TGC4,BIT, /*
  395. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  396. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  397. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  398. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, DSO, BIT, BIT, BIT, BIT, /*
  399. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  400. BIT, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  401. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  402. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, BIT, BIT, BIT, BIT, NON,
  403. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  404. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  405. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  406. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  407. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  408. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  409. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT,
  410. BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT, NON
  411. };
  412. /*      bit  nmc  nu   nms  spc  non  ee   eob  rs   com  eti  grpo lit  lita
  413.         dso  pero plus refc rni  tagc tago vi   */
  414. #undef BIT
  415. #undef NMC
  416. #undef NU
  417. #undef NMS
  418. #undef SPC
  419. #undef NON
  420. #undef EE
  421. #undef EOB
  422. #undef RS
  423. #undef COM1
  424. #undef ETIB
  425. #undef GRPO
  426. #undef LIT3
  427. #undef LITA
  428. #undef DSO
  429. #undef PERO
  430. #undef PLUS
  431. #undef REFC
  432. #undef RNI
  433. #undef TGC4
  434. #undef TGO4
  435. #undef VI
  436. /******************************************************************************/
  437. /* LEXTRAN: Translation table for SGML names.
  438. */
  439. UNCH lextran[256] = { /*
  440. 000  001 002   003   004  005  006  007      bs   tab  lf   home    ff     cr   so     si   */
  441. 0  , 1  , 2  , 3  , 4  , 5  , 6  , 7  , 8  , 9  , 10 , 11 , 12 , 13 , 14 , 15 , /*
  442. 010  011   012  013  014   015   016  017  020  021    eof  esc  rt   left up   down */
  443. 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , /*
  444. space!    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  445. 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , /*
  446. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  447. 48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , /*
  448. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  449. 64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , /*
  450. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  451. 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , /*
  452. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  453. 96 , 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /*
  454. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  455. 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 123, 124, 125, 126, 127,
  456. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  457. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  458. 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 173, 173, 174, 175,
  459. 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
  460. 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
  461. 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
  462. 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
  463. 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
  464. };
  465. /******************************************************************************/
  466. #include "lextoke.h"          /* Symbols for tokenization lexical classes. */
  467. /******************************************************************************/
  468. /* LEXTOKE: Lexical class table for tokenization scan.
  469. */
  470. UNCH lextoke[256] = { /*
  471.  
  472. 000  001  002  003  004  005  006  007  bs   tab  lf  home  ff   cr   016  017  */
  473. INV, INV, INV, INV, INV, INV, INV, INV, INV, SEP, REC, INV, INV, REC, INV, INV, /*
  474. 020 021 022  023 024  025 026 027 030  031  eof  esc  rt   left up   down */
  475. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, EOB, INV, INV, INV, /*
  476. space!    "    #    $    %    &    '    (    )    *    +    ,    -    .    /    */
  477. SEP, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, NMC, NMC, INV, /*
  478. 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ?    */
  479. NU , NU , NU , NU , NU , NU , NU , NU , NU , NU , INV, INV, INV, INV, INV, INV, /*
  480. @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O    */
  481. INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  482. P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _    */
  483. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV, /*
  484. `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o    */
  485. INV, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, /*
  486. p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~    127  */
  487. NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, NMS, INV, INV, INV, INV, INV,
  488. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  489. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  490. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  491. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  492. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  493. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  494. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV,
  495. INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV, INV
  496. };
  497. /******************************************************************************/
  498. struct lexical lex = {        /* Delimiter set constants for parser use. */
  499.      {                        /* Markup strings for text processor use. */
  500.           (UNCH *)"\4&#",                  /* LEXCON markup string: CRO        */
  501.           (UNCH *)"[",                     /* LEXCON markup string: DSO        */
  502.           (UNCH *)"\3&",                   /* LEXCON markup string: ERO        */
  503.           (UNCH *)"\4</",                  /* LEXMARK markup string: end-tag   */
  504.           (UNCH *)"\3\"",                  /* LEXMARK markup string: LIT       */
  505.           (UNCH *)"\3'",                   /* LEXMARK markup string: LITA      */
  506.           (UNCH *)"\3>",                   /* LEXCON markup string: MDC        */
  507.           (UNCH *)"\4<!",                  /* LEXCON markup string: MDO        */
  508.           (UNCH *)"\5]]>",                 /* LEXCON markup string: mse        */
  509.           (UNCH *)"\5<![",                 /* LEXCON markup string: mss        */
  510.           (UNCH *)"\13<![CDATA[",          /* LEXCON markup string: mss CDATA  */
  511.           (UNCH *)"\14<![RCDATA[",         /* LEXCON markup string: mss RCDATA */
  512.           (UNCH *)"\3>",                   /* LEXCON markup string: PIC        */
  513.           (UNCH *)"\4<?",                  /* LEXCON markup string: PIO        */
  514.           (UNCH *)"\3;",                   /* LEXGRP markup string: ref close. */
  515.           (UNCH *)"\3<",                   /* LEXMARK markup string: start-tag */
  516.           (UNCH *)"\3>",                   /* LEXMARK markup string: TAGC      */
  517.           (UNCH *)"\3=",                   /* LEXMARK markup string: VI        */
  518.           3,                       /* LEXMARK: length of null end-tag. */
  519.           2                        /* LEXMARK: length of null start-tag. */
  520.      },
  521.      {                        /* Short reference delimiters. */
  522.           {                        /* Short reference delimiter table. */
  523.                {(UNCH *)"",       SRCT},        /* Dummy entry to store SR count. */
  524.                {(UNCH *)"\t",     1},           /* TAB */
  525. #ifdef applec
  526.                {(UNCH *)"\n",     2},           /* RE */
  527.                {(UNCH *)"\r",     3},           /* RS */
  528.                {(UNCH *)"\rB",    4},           /* Leading blanks */
  529.                {(UNCH *)"\r\n",   5},           /* Null record */
  530.                {(UNCH *)"\rB\n",  6},           /* Blank record */
  531.                {(UNCH *)"B\n",    7},           /* Trailing blanks */
  532. #else
  533.                {(UNCH *)"\r",     2},           /* RE */
  534.                {(UNCH *)"\n",     3},           /* RS */
  535.                {(UNCH *)"\nB",    4},           /* Leading blanks */
  536.                {(UNCH *)"\n\r",   5},           /* Null record */
  537.                {(UNCH *)"\nB\r",  6},           /* Blank record */
  538.                {(UNCH *)"B\r",    7},           /* Trailing blanks */
  539. #endif
  540.                {(UNCH *)" ",      8},           /* Space */
  541.                {(UNCH *)"BB",     9},           /* Two or more blanks */
  542.                {(UNCH *)"\"",    10},           /* Quotation mark (first data character) */
  543.                {(UNCH *)"#",     11},           /* Number sign */
  544.                {(UNCH *)"%",     12},           /* FCE CHARACTERS start here */
  545.                {(UNCH *)"'",     13},
  546.                {(UNCH *)"(",     14},
  547.                {(UNCH *)")",     15},
  548.                {(UNCH *)"*",     16},
  549.                {(UNCH *)"+",     17},
  550.                {(UNCH *)",",     18},
  551.                {(UNCH *)"-",     19},           /* Hyphen */
  552.                {(UNCH *)"--",    20},           /* Two hyphens */
  553.                {(UNCH *)":",     21},
  554.                {(UNCH *)";",     22},
  555.                {(UNCH *)"=",     23},
  556.                {(UNCH *)"@",     24},
  557.                {(UNCH *)"[",     25},
  558.                {(UNCH *)"]",     26},
  559.                {(UNCH *)"^",     27},
  560.                {(UNCH *)"_",     28},           /* Low line */
  561.                {(UNCH *)"{",     29},
  562.                {(UNCH *)"|",     30},
  563.                {(UNCH *)"}",     31},
  564.                {(UNCH *)"~",     32},
  565.                {NULL,     0}
  566.           },
  567.           {                        /* Printable form of unprintable SR delims.*/
  568.                (UNCH *)"",                      /* Dummy entry to balance s.dtb. */
  569.                (UNCH *)"&#TAB;",                /* TAB */
  570.                (UNCH *)"&#RE;",                 /* RE */
  571.                (UNCH *)"&#RS;",                 /* RS */
  572.                (UNCH *)"&#RS;B",                /* Leading blanks */
  573.                (UNCH *)"&#RS;&#RE;",            /* Null record */
  574.                (UNCH *)"&#RS;B&#RE;",           /* Blank record */
  575.                (UNCH *)"B&#RE;",                /* Trailing blanks */
  576.                (UNCH *)"&#SPACE;"               /* Space */
  577.           },
  578.           12,                      /* LEXCNM: Index of first FCE in srdeltab. */
  579.           20,                      /*LEXCNM:Index of "two hyphens" in srdeltab*/
  580.           10,                      /* LEXCNM: Index of first SR with data char. */
  581.           19,                      /* LEXCNM: Index of hyphen in srdeltab. */
  582.           SRNPRT+1,                /* LEXCNM: Index of 1st printable SR. */
  583.           8,                       /* LEXCNM: Index of space in srdeltab. */
  584.      },                       /* End of short reference delimiters. */
  585.      {                        /* General delimiter characters. */
  586.           '\b',                    /*LEXCNM:(BS)Generated RE; can't be markup.*/
  587.           '"',                     /* LEXMARK: Char used as LIT delimiter.*/
  588.           '\'',                    /* LEXMARK: Char used as LITA delimiter.*/
  589.           '>',                     /* LEXLMS: Char used as MDC delimiter.*/
  590.           ']',                     /* LEXLMS: Char used as MSC when enabled.*/
  591.           '/',                     /* LEXCON: Char used as NET when enabled.*/
  592.           '%',                     /* LEXMARK: Char used as PERO delimiter. */
  593.           '>',                     /* LEXCON: Char used as PIC delimiter.*/
  594.           '<'                      /* LEXCON: Char used as TAGO when enabled.*/
  595.      },
  596.      {                        /* Lexical table code assignments. */
  597.           FCE,                    /* LEXCNM: FRE char as entity reference.*/
  598.           FRE,                    /* LEXLMS: Free character not an entity ref.*/
  599.           LITC,                   /* LEXLMS: Literal close delimiter enabled. */
  600.           NSC,                    /* LEXLMS: Non-SGML character prefix. */
  601.           MSC3,                   /* LEXLMS: Marked section close delim enabled. */
  602.           NET,                    /* LEXCON: Null end-tag delimiter enabled. */
  603.           ETI,                    /* LEXCON: NET disabled; still used as ETI. */
  604.           SPCR,                   /* LEXCNM: Space in use as SHORTREF delim. */
  605.           TGO2,                   /* LEXCON: Tag open delimiter enabled. */
  606.           CDE                     /* LEXLMS: CDATA/SDATA delimiters. */
  607.      }
  608. };
  609. /******************************************************************************/
  610.